package com.stellar.circle.controller.miniApp.sCommentLike;


import com.google.common.base.Preconditions;
import com.stellar.circle.domain.sCommentLike.SCommentLikeDomainService;

import com.stellar.web.core.bean.Result;
import com.stellar.web.core.constants.AuthUserConstants;
import com.stellar.web.core.validator.ValidatorRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 评论点赞表控制器
 *
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-19 14:53:10
 */
@RequestMapping("/api-miniApp/sCommentLike")
@RestController("miniAppSCommentLikeController")
@Slf4j
public class SCommentLikeController {

    @Resource
    private SCommentLikeDomainService sCommentLikeDomainService;

    /**
     * 点赞评论
     */
    @ValidatorRole(value = {AuthUserConstants.SUPER_ADMIN, AuthUserConstants.SCHOOL_ADMIN, AuthUserConstants.NORMAL_USER})
    @PostMapping("/like")
    public Result<Boolean> like(@RequestParam Long id) {
        try {
            if (log.isInfoEnabled()) {
                Preconditions.checkNotNull(id, "评论Id不能为空");
            }
            Boolean result = sCommentLikeDomainService.like(id);
            if (!result) return Result.fail(result);
            return Result.success(result);
        } catch (IllegalArgumentException iae) {
            log.error("SCommentLikeController.like.error:{}", iae.getMessage());
            return Result.fail(iae.getMessage());
        }

    }
}


